package main.entity;

import java.math.BigDecimal;
import java.util.ArrayList;

import main.math.Calculator;
import main.math.ConvertUtils;

public class Hero {

	private String name;

	private BigDecimal initialGold;
	private BigDecimal initialDPS;
	
	private int position;

	private Skill[] skillz;

	public Hero(BigDecimal gold, int position) {
		this.initialGold = gold;
		this.position = position;
		this.initialDPS = Calculator.getInitialDPS(initialGold, position);
	}
	
	public Hero(String name, BigDecimal gold, int position, Skill... skills) {
		this.name = name;
		this.initialGold = gold;
		this.position = position;
		this.initialDPS = Calculator.getInitialDPS(initialGold, position);
		if (skills == null || skills.length == 0 || skills[0] == null) {
			skillz = null;
		} else {
			this.skillz = skills;
		}
	}

	public void printHeroValues(){
		System.out.println(position+" - "+name+" - "+ ConvertUtils.getFamiliarName(initialDPS) +" - "+initialDPS);
		System.out.println(position+" - "+name+" - "+ ConvertUtils.getFamiliarName(initialGold) +" - "+initialGold);
		System.out.println("\n");
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BigDecimal getInitialGold() {
		return initialGold;
	}

	public void setInitialGold(BigDecimal initialGold) {
		this.initialGold = initialGold;
	}

	public BigDecimal getInitialDPS() {
		return initialDPS;
	}

	public void setInitialDPS(BigDecimal initialDPS) {
		this.initialDPS = initialDPS;
	}

	public Skill[] getSkillz() {
		return skillz;
	}

	public void setSkillz(Skill[] skillz) {
		this.skillz = skillz;
	}

	public Skill[] getSkillsBefore(int level) {
		ArrayList<Skill> list = new ArrayList<>();

		if (skillz != null && skillz.length > 0) {

			for (Skill skill : skillz) {
				if (skill.getLevel() <= level) {
					list.add(skill);
				}
			}
		}

		if (list == null || list.isEmpty()) {
			return null;
		} else {
			return list.toArray(new Skill[1]);
		}
	}

	public static Hero getTreeBeast() {
		
		Hero hero = new Hero("Treebeast", new BigDecimal("50"),
				2, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		

	}
	public static Hero getIvan() {
		
		Hero hero = new Hero("Ivan", new BigDecimal("250"),
				3, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(125, 1.5));
		
		return hero;
		
		
	}
	public static Hero getBrittany() {
		
		Hero hero = new Hero("Brittany", new BigDecimal("1000"),
				4, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getFisherman() {
		
		Hero hero = new Hero("Fisherman", new BigDecimal("4000"),
				5, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 0.25));
		
		return hero;
		
		
	}
	public static Hero getBetty() {
		
		Hero hero = new Hero("Betty", new BigDecimal("20000"),
				6, Skill.get(10, 0.20), Skill.get(25, 0.20),
				Skill.get(50, 0.20), Skill.get(75, 0.20));
		
		return hero;
		
		
	}
	public static Hero getMaskedSamurai() {
		
		Hero hero = new Hero("Masked Samurai", new BigDecimal("100000"),
				7, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getLeon() {
		
		Hero hero = new Hero("Leon", new BigDecimal("400000"),
				8, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 0.25));
		
		return hero;
		
		
	}
	public static Hero getForestSeer() {
		
		Hero hero = new Hero("Forest Seer", new BigDecimal("2500000"),
				9, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getAlexa() {
		
		Hero hero = new Hero("Alexa", new BigDecimal("15000000"),
				10, Skill.get(25, 1.25),
				Skill.get(50, 1.25));
		
		return hero;
		
		
	}
	public static Hero getNathalia() {
		
		Hero hero = new Hero("Nathalia", new BigDecimal("100000000"),
				11, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getMercedes() {
		
		Hero hero = new Hero("Mercedes", new BigDecimal("800000000"),
				12, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getBobby() {
		
		Hero hero = new Hero("Bobby", new BigDecimal("6500000000"),
				13, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getBroyle() {
		
		Hero hero = new Hero("Broyle", new BigDecimal("50000000000"),
				14, Skill.get(10, 0.25), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getSirGeorge() {
		
		Hero hero = new Hero("Sir George II", new BigDecimal("450000000000"),
				15, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getKingMidas() {
		
		Hero hero = new Hero("King Midas", new BigDecimal("4000000000000"),
				16);
		
		return hero;
		
		
	}
	
	public static Hero getRefri() {
		
		Hero hero = new Hero("Refri Jerator", new BigDecimal("36000000000000"),
				17, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1), Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	public static Hero getAbaddon() {
		
		Hero hero = new Hero("Abaddon", new BigDecimal("320000000000000"),
				18, Skill.get(10, 1.25), Skill.get(25, 1.25),
				Skill.get(50, 1.25));
		
		return hero;
		
		
	}
	public static Hero getMaZhu() {
		
		Hero hero = new Hero("Ma Zhu", new BigDecimal("2700000000000000"),
				19, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1),Skill.get(75, 1.5));
		
		return hero;
		
		
	}
	
	public static Hero getAmenhotep() {
		
		Hero hero = new Hero("Amenhotep", new BigDecimal("24000000000000000"),
				20, Skill.get(10, 1), Skill.get(25, 0.20),
				Skill.get(50, 0.20));
		
		return hero;
		
		
	}
	
	public static Hero getBeastlord() {
		
		Hero hero = new Hero("Beastlord", new BigDecimal("300000000000000000"),
				21, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1),Skill.get(75, 0.1));
		
		return hero;
		
		
	}
	public static Hero getAthena() {
		
		Hero hero = new Hero("Athena", new BigDecimal("9000000000000000000"),
				22, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1),Skill.get(75, 1));
		
		return hero;
		
		
	}
	public static Hero getAphrodite() {
		
		Hero hero = new Hero("Aphrodite", new BigDecimal("350000000000000000000"),
				23, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 1));
		
		return hero;
		
		
	}
	public static Hero getShinatobe() {
		
		Hero hero = new Hero("Shinatobe", new BigDecimal("14000000000000000000000"),
				24, Skill.get(10, 1), Skill.get(25, 0.1),
				Skill.get(50, 1),Skill.get(75, 1));
		
		return hero;
		
		
	}
	public static Hero getGrant() {
		
		Hero hero = new Hero("Grant", new BigDecimal("4199999999999990000000000"),
				25, Skill.get(10, 0.25), Skill.get(25, 1),
				Skill.get(50, 0.25),Skill.get(75, 1));
		
		return hero;
		
		
	}
	public static Hero getFrostleaf() {
		
		Hero hero = new Hero("Frostleaf", new BigDecimal("2100000000000000000000000000"),
				26, Skill.get(10, 1), Skill.get(25, 1),
				Skill.get(50, 0.25));
		
		return hero;
		
		
	}
	// Hero base costs, in order from Cid to Frostleaf: 10, 50, 250, 1000, 4000,
	// 20000, 100000, 400000, 2500000, 15000000, 100000000, 800000000,
	// 6500000000, 50000000000, 450000000000, 4000000000000, 36000000000000,
	// 320000000000000, 2700000000000000, 24000000000000000, 300000000000000000,
	// 9000000000000000000, 350000000000000000000, 14000000000000000000000,
	// 4199999999999990000000000, 2100000000000000000000000000

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}
}
